package com.zhaoyizhe.demo;

import com.zhaoyizhe.demo.component.UserComponent;
import com.zhaoyizhe.demo.configuration.UserConfiguration;
import com.zhaoyizhe.demo.controller.UserController;
import com.zhaoyizhe.demo.repository.UserRepository;
import com.zhaoyizhe.demo.service.UserService;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;

@SpringBootApplication
public class SpringiocDiApplication {

	public static void main(String[] args) {
		ApplicationContext context = SpringApplication.run(SpringiocDiApplication.class, args);
		UserController controller = context.getBean(UserController.class);
		controller.sayHi();

		UserService service = context.getBean(UserService.class);
		service.sayHi();

		UserRepository repository = (UserRepository) context.getBean("userRepository");
		repository.sayHi();

		UserComponent userComponent1 = context.getBean("getUserComponent1",UserComponent.class);
		System.out.println(userComponent1);
		UserComponent userComponent2 = context.getBean("getUserComponent2",UserComponent.class);
		System.out.println(userComponent2);

		UserConfiguration userConfiguration = context.getBean(UserConfiguration.class);
		userConfiguration.function();
	}

}
